/*
 * @Author: 智永风
 * @Date: 2024-12-11 09:25:45
 * @LastEditors: zhiyongfeng 18730312382@163.com
 * @LastEditTime: 2025-01-22 16:39:17
 * @FilePath: \zhlx-autoform-ui\src\api\document\serial.ts
 * @Description:
 *
 * Copyright (c) 2024 by 智永风, All Rights Reserved.
 */
import service from "@/utils/request"

// 流水号

/**
 * 获取流水号列表
 * @param query 查询参数
 * @returns 返回请求Promise对象
 */
export const getSerialNumListAPI = (query: object) => {
  return service({
    url: "/document/flowingWater/page",
    method: "get",
    params: query,
  })
}

/**
 * 获取授权后的列表信息
 * @param query 查询参数 可传该对象字段值（对象字段值与保存时的字段值一样） 不需要查询可不传值
 * @returns 返回请求Promise对象
 */
export function getAuthSerialNumAPI(query: object) {
  return service({
    // url: `/document/flowingWater/list`,
    url: `/document/flowingWaterManagement/fetchSerial`,
    method: "get",
    params: query,
  })
}

/**
 * 文单与流水号进行绑定
 * @param data 待绑定数据
 * 	"id":"1800065626283442177",	流水号id规则
 *  "formId":"1111", 文单id
 *  "formName":"XXX公文单", 文单名称
 * @returns 返回请求Promise对象
 */
export function bindSerialNumAPI(data: object) {
  return service({
    url: `/document/flowingWater/updateFlowingWaterData`,
    method: "post",
    data,
    headers: {
			CustomErrorHandler: true
		}
  })
}

/**
 * 根据id获取规则信息
 * @param formId 文单id
 * @returns 返回请求Promise对象
 */
export function getSerialRuleByFormIdAPI(data) {
  return service({
    url: `/document/flowingWaterManagement/getFlowingWaterDuplicateReferences`,
    method: "get",
    params: data,
  })
}

/**
 * 根据文单id获取流水号
 * @param formId 文单id
 * @returns 返回请求Promise对象
 */
export function getSerialNumByFormIdAPI(formId: any) {
  return service({
    url: `/document/flowingWater/getOneFlowingWater/${formId}`,
    method: "get",
  })
}

/**
 * 根据id获取详细信息(高级模式)
 * @param id 流水号id
 * @returns 返回请求Promise对象
 */
export function getDetailSenior(data: object) {
  return service({
    url: "/document/flowingWaterManagement/getTurnoverCodeById",
    method: "get",
    params: data
  })
}

/**
 * 查看断号
 * @param id 流水号id
 * @returns 返回请求Promise对象
 */
export function getBreakNumber(data: object) {
  return service({
    url: "/document/flowingWaterManagementRulesSerial/pageBroken",
    method: "get",
    params: data,
  })
}
